<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr = ["a", "b", "c", "d", "e", "g"];
      console.log(arr);
      console.log(arr.slice(1, 5));
      console.log(arr.slice(1, -3));
      console.log(arr.slice(-5, -2));
      console.log(arr.slice(1));
      console.log(arr.slice(-1)); //获取最后一个元素
      // console.log(arr.slice(-2, -5)); 前小后大
      const newArr = arr.slice(0); // 复制数组

      console.log(newArr, newArr === arr); //false
    </script>
  </body>
</html>
